﻿using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SmartCity.BasicData.Api.Application.Commond.ADepartMent;
using SmartCity.BasicData.Api.Application.Commond.AdminSetting;
using SmartCity.BasicData.Api.Application.Commond.Login;
using SmartCity.BasicData.Common;
using SmartCity.BasicData.Domain;
using SmartCity.BasicData.Domain.DTO;

namespace SmartCity.BasicData.Api.Controllers
{
    /// <summary>
    /// Account 控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class AccountController : ControllerBase
    {
        private readonly IMediator mediator;
        /// <summary>
        /// 通过构造函数注入中介者组件
        /// </summary>
        /// <param name="mediator"></param>
        public AccountController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="loginRequest"></param>
        /// <returns></returns>
        [HttpGet]
        [AllowAnonymous]
        public Task<ApiResult<AccountModel>> Login([FromQuery] LoginRequestCommand loginRequest)
        {
            return mediator.Send(loginRequest);
        }
        [HttpGet]
        public Task<ApiResult<IList<AccountDepartmentDTO>>> GetAccountsWithDepart([FromQuery] AccountLIstSearchCommand request)
        {
            return mediator.Send(request);
        }


    }
}
